package com.sc.nft.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.sc.nft.dao.ActivityTaskRelationDao;
import com.sc.nft.entity.ActivityTaskRelation;
import com.sc.nft.entity.dto.ActivityTaskDTO;
import com.sc.nft.service.ActivityTaskRelationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (ActivityTaskRelation)表服务实现类
 *
 * @author 王伟成
 * @since 2023-09-15 14:06:56
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class ActivityTaskRelationServiceImpl implements ActivityTaskRelationService {

    private final ActivityTaskRelationDao activityTaskRelationDao;
    @Override
    public void save(List<ActivityTaskDTO> list, Long activityBasicsId) {
        List<ActivityTaskRelation> activityTaskRelations = BeanUtil.copyToList(list, ActivityTaskRelation.class);
        activityTaskRelations.forEach(activityTaskRelation -> {
            activityTaskRelation.setActivityId(activityBasicsId);
        });
        activityTaskRelationDao.saveBatch(activityTaskRelations);
    }
    @Override
    public void deleteByActivityBasicsId(Long activityBasicsId) {
        activityTaskRelationDao.deleteByActivityBasicsId(activityBasicsId);
    }
}
